const app = {
  state: {
    token: localStorage.getItem('token'),
    userinfo: {},
    wxFetHost: ''
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_USERINFO: (state, data) => {
      state.userinfo = data
    },
    SET_WXHOST: (state, wxHost) => {
      state.wxFetHost = wxHost
      localStorage.setItem('wxHost', wxHost)
    }
  },
  actions: {
    SET_WXHOST: ({ commit }) => {
      commit('SET_WXHOST')
    },
    SET_TOKEN: ({ commit }, data) => {
      commit('SET_TOKEN', data)
    },
    SET_USERINFO: ({ commit }, data) => {
      commit('SET_USERINFO', data)
    }
  }
}

export default app
